<script>
  

    function hitung() {
        $('#total').val($("#service").val().split('|')[1] * $("#unit").val());
    }
    
    function post() {
        $.post('<?php echo base_url(); ?>reservation/saveEditServ/', {
            service_id: $("#service").val().split('|')[0],
            jumlah: $("#unit").val(),
            total: $('#total').val(),
            desc:$('#desc').val(),
            resv_serv_id: <?php echo $data['resv_serv_id']; ?>
        }, function() {
            window.location.replace("../reservation");
        });
    }

</script>
<table class="table">
    <tr>
        <td>Pilih Service</td>
        <td>
            <select id="service">
                <?php
                foreach ($data2 as $row) {
                    echo '<option ';
                    if($row['service_id'] == $data['service_id']){
                        echo 'selected';
                    }
                    echo ' value="' . $row['service_id'] . '|' . $row['service_price'] . '" >' . $row['service_name'] . '</option>';
                }
                ?></select><span id="price"></span>
        </td>
    </tr>
    <tr>
        <td>Jumlah</td>
        <td>
            <input id="unit" type="number" value="<?php echo $data['resv_serv_unit']; ?>"/> <a class="btn btn-primary" href="javascript:void(0)" onclick="javascript:hitung();">=</a>
        </td>
    </tr>

    <tr>
        <td>Total</td>
        <td>
            <input id="total" type="number" value="<?php echo $data['resv_serv_total']; ?>" disabled/>
        </td>
    </tr>

    <tr>
        <td>Deskripsi</td>
        <td>
            <textarea id="desc"><?php echo $data['resv_serv_desc']; ?></textarea>
        </td>
    </tr>
</table>
<a class="btn btn-primary" href="javascript:void(0)" onclick="javascript:post();">Save</a>
